package texture;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public abstract class Stitcher {
	protected final int maxWidth;
	protected final int maxHeight;

	protected int currentWidth;
	protected int currentHeight;

	protected final boolean forcePowerOf2;
	protected final int maxTileDimension;

	protected HashSet<StitchHolder> setStitchHolders;
	protected List<StitchSlot> stitchSlots;

	public Stitcher(int maxWidth, int maxHeight, boolean forcePowerOf2, int maxTileDimension) {
		this.maxWidth = maxWidth;
		this.maxHeight = maxHeight;

		this.forcePowerOf2 = forcePowerOf2;
		this.maxTileDimension = maxTileDimension;

		this.setStitchHolders = new HashSet<>(256);
		this.stitchSlots = new ArrayList<>(256);
	}

	public int getCurrentWidth() {
		return this.currentWidth;
	}

	public int getCurrentHeight() {
		return this.currentHeight;
	}

	public void addSprite(TextureAtlasSprite textureAtlasSprite) {
		StitchHolder stitchholder = new StitchHolder(textureAtlasSprite);
		if (this.maxTileDimension > 0) {
			stitchholder.setNewDimension(this.maxTileDimension);
		}
		this.setStitchHolders.add(stitchholder);
	}

	public abstract void doStitch();

	public abstract List<TextureAtlasSprite> getStichSlots();
}